# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=task
pkgver=2.5.1
pkgrel=2
pkgdesc="A command-line to-do list manager"
url="https://taskwarrior.org"
arch="all"
license="MIT"
makedepends="cmake gnutls-dev util-linux-dev"
subpackages="$pkgname-doc
	$pkgname-bash-completion:bashcomp:noarch
	$pkgname-fish-completion:fishcomp:noarch
	$pkgname-zsh-completion:zshcomp:noarch"
source="https://taskwarrior.org/download/task-$pkgver.tar.gz
	musl-fix.patch"

build() {
	cmake . \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr
	make
}

package() {
	make DESTDIR="$pkgdir" install
}

bashcomp() {
	pkgdesc="Bash completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel bash-completion"

	install -Dm644 "$builddir"/scripts/bash/$pkgname.sh \
		"$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

fishcomp() {
	pkgdesc="Fish completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel fish"

	install -Dm644 "$builddir"/scripts/fish/$pkgname.fish \
		"$subpkgdir"/usr/share/fish/completions/$pkgname.fish
}

zshcomp() {
	pkgdesc="Zsh completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	install -Dm644 "$builddir"/scripts/zsh/_$pkgname \
		"$subpkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="ec17e5cefff55ecd2c1cb717801c02683d94030906c8d86450c3c79c0bc5a18d82559a5e9e26a91411a1025a241b78ddbc1de51cafc1a2dd531e8229e5e61c10  task-2.5.1.tar.gz
f82f9883ef6c885635890453fbb5c1dc4d4bf4b69926962a643bcaeadeb80874200329c3916b9796d26fd5f28eb9ad20f50fe7e4adc9f9ca635aa4b50be81911  musl-fix.patch"
